<?php

/**
 * @Author: Kendy
 * @Date:   2019-10-22 10:33:15
 * @Last Modified by:   jiayanting
 * @Last Modified time: 2020-03-26 15:49:12
 */ 
namespace app\api\controller;
use think\Db;
use think\Request;
use app\api\model\GroupTour as gt;
class Grouptour extends Nocommon
{ 
    /**
     * @Author   Kendy
     * @DateTime 2019-10-22T10:59:57+0800
     * 跟团产品列表
     */
	public function groupTourList()
	{ 
    	 if(Request::instance()->isPost()){  
          $groupTour = new gt(); 
          $gtour_type = input('gtours_type'); 
          $keyword = input('keyword');  
          if($keyword!='')$where['gtour_title'] = ['like','%'.$keyword.'%'];
          if(!empty($gtour_type))$where['gtours_type'] = $gtour_type;          
          $page = $this->p();
          $page = ($page-1)*config('page_size');
          $where['is_del'] = 0;
          $where['is_display'] = 0;
          $where1 = [];
          $orderBy = input('order_by');  
          $sprice = input("post.sprice");//开始价格
          $eprice = input("post.eprice");//结束价格
          if($sprice!="" && $eprice!="") 
            $where1['tg_price'] = ['between',''.$sprice.','.$eprice.'']; 

           $stg_date = input("post.start_time");//开始时间
           $etg_date = input("post.end_time");//结束时间
           if($stg_date!="" && $etg_date!="") 
            $where1['tg_date'] = ['between',''.strtotime($stg_date).','.strtotime($etg_date).''];    
          $GroupTourList = $groupTour->GetGroupTourList($where,$where1,$page,'',$orderBy);  
          return $this->apiReturn('200','成功',$GroupTourList);
        }
   }
     /**
      * [getGroupTourInfo 获取跟团游详情]
      * @Author   Kendy
      * @DateTime 2019-10-22T16:56:25+0800
      * @return   [type]                   [description]
      */
    public function getGroupTourInfo()
    {
        if(Request::instance()->isPost()){  
          $groupTour = new gt(); 
          $gt_id = input('post.gt_id/d');   
          if(empty($gt_id))
             return $this->apiReturn('400','请输入跟团id',0);
          $GroupTourInfo = $groupTour->getGroupTourInfo($gt_id);  
          return $this->apiReturn('200','成功',$GroupTourInfo);
        }
    }

     /**
  * [gtourGscheduleList 选择班期接口]
  * @Author   kendy
  * @DateTime 2019-11-08T11:43:42+0800
  * @return   [type]                   [description]
  */
  public function gtourGscheduleList()
  {
    if(Request::instance()->isPost()){  
        $tg_id = (int)input('post.tg_id');
        if(empty($tg_id)) return $this->apiReturn('400','跟团游id为空',0);
        $groupTour = new gt(); 
        $result = $groupTour->getGscheduleListById($tg_id);
        return $this->apiReturn('200','成功',$result);
   }
 }
 
}